const Pager = require('../../components/aotoo/core/index')
let lib = Pager.lib


module.exports = function mkDropdown(params) {
  let dft = {
    id: lib.suid('m-'),
    type: 'modal',
    direction: 'middle',      //弹出层方向
    animate: true,            //是否动画
    full: false,              //是否全屏
    actionSideClass: '',      //弹出层第二层的样式
    actionSideWrapClass: '',  //弹出层第二层的样式
    close: false,
    closeCustom: {},        //可自定义close内容 close为true时成立
    mask: true
  }

  let opts = Object.assign({}, dft, params)
  opts.type === 'toast' ? opts.mask = false : ''
  let modalClose = opts.close ? opts.closeCustom ? opts.closeCustom :
  {
    title: ' ',
    itemClass: 'icon-close',
    aim: 'onHide',
  }
  : ''
  return {   
    $$id: opts.$$id || opts.id,
    title: [
      {
        '@item': opts.data,
        itemClass: opts.direction === 'bottom' ? 'ss-safe-bottom' : ''
      },
      ...modalClose
    ],
    dot: opts.mask ? [{title: ' ', itemClass: 'actionSide-mask', aim: 'onHide'}] : [],
    titleClass: opts.type === 'modal' ? ('actionSide-common actionSide-'+opts.direction+(opts.animate ? ' animate' : '')+(!opts.full ? ' bar' : '')+' '+opts.actionSideClass) : 'ui-item-flex-first flex-row-between',
    itemClass: opts.type === 'modal' ? ('actionSide-wrapper ' + opts.actionSideWrapClass) : opts.actionSideWrapClass || 'toast-body',
    methods:{
      onHide(e) {
        // if (opts.type === 'modal') {
        //   this.update({titleClass:( 'actionSide-common actionSide-'+opts.direction+(opts.animate ? ' removeAnimation animate' : '')+(!opts.full ? ' bar' : '')+' '+opts.actionSideClass), dot: []})
        //   setTimeout(() => {
        //     this.reset({})
        //   }, 200);
        // }
        // else {
          this.reset()
        // }
      }
    }
  }
}

 
// abc({
//   data: {},
//   full: false,
//   type: 'modal',
//   direction: 'middle'
// })